package zhishuang.wang.sansi.playlist.entry;

/**
 * @Author Zhishuang.Wang
 * @Date 2023/7/5 11:09
 * @Email 1406110602@qq.com
 */

import zhishuang.wang.sansi.tools.ReturnData;

public class PlayArea {
    private Integer startPosition;
    private Integer endPosition;
    private Integer validFlag;

    public PlayArea(int validFlag, int startPosition, int endPosition) {
        this.validFlag = validFlag;
        this.startPosition = startPosition;
        this.endPosition = endPosition;
    }

    public ReturnData checkParam() {
        ReturnData rd = new ReturnData();
        rd.setCode(1);
        String errorMes = "";
        if (this.validFlag != null) {
            if (this.validFlag >= 0 && this.validFlag <= 1) {
                if (this.validFlag == 1) {
                    if (this.startPosition == null || this.startPosition < 0) {
                        errorMes = errorMes + "开始播放位置，取值大于等于0；";
                    }

                    if (this.endPosition == null || this.endPosition < this.startPosition) {
                        errorMes = errorMes + "结束播放位置，必须大于等于开始播放位置；";
                    }
                }
            } else {
                errorMes = errorMes + "生效标志，取值范围：0 或 1；";
            }
        }

        if (errorMes == null || errorMes.length() == 0) {
            rd.setCode(0);
        }

        return rd;
    }

    public Integer getStartPosition() {
        return this.startPosition;
    }

    public void setStartPosition(Integer startPosition) {
        this.startPosition = startPosition;
    }

    public Integer getEndPosition() {
        return this.endPosition;
    }

    public void setEndPosition(Integer endPosition) {
        this.endPosition = endPosition;
    }

    public Integer getValidFlag() {
        return this.validFlag;
    }

    public void setValidFlag(Integer validFlag) {
        this.validFlag = validFlag;
    }
}
